/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

// Created on 27.11.2003 by RST.
//$Id: client_state_t.java,v 1.5 2005/11/21 19:38:38 cawe Exp $
using System;
using Defines = Suake2.UI.Defines;
using cmodel_t = Suake2.UI.game.cmodel_t;
using usercmd_t = Suake2.UI.game.usercmd_t;
using image_t = Suake2.UI.render.image_t;
using model_t = Suake2.UI.render.model_t;
using Suake2.UI.sound;
//UPGRADE_TODO: The type 'java.nio.ByteBuffer' could not be found. If it was not included in the conversion, there may be compiler issues. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1262'"
using ByteBuffer = java.nio.ByteBuffer;
namespace Suake2.UI.client
{
	
	public class client_state_t
	{
		private void  InitBlock()
		{
			cmds = new usercmd_t[Defines.CMD_BACKUP];
			cmd_time = new int[Defines.CMD_BACKUP];
			for (int i = 0; i < Defines.CMD_BACKUP; i++)
			{
				predicted_origins[i] = new short[3];
			}
			predicted_origins = new short[Defines.CMD_BACKUP][];
			frames = new frame_t[Defines.UPDATE_BACKUP];
			inventory = new int[Defines.MAX_ITEMS];
			configstrings = new System.String[Defines.MAX_CONFIGSTRINGS];
			model_draw = new model_t[Defines.MAX_MODELS];
			model_clip = new cmodel_t[Defines.MAX_MODELS];
			sound_precache = new sfx_t[Defines.MAX_SOUNDS];
			image_precache = new image_t[Defines.MAX_IMAGES];
			clientinfo = new clientinfo_t[Defines.MAX_CLIENTS];
		}
		
		public client_state_t()
		{
			InitBlock();
			for (int n = 0; n < Defines.CMD_BACKUP; n++)
				cmds[n] = new usercmd_t();
			for (int i = 0; i < frames.Length; i++)
			{
				frames[i] = new frame_t();
			}
			
			for (int n = 0; n < Defines.MAX_CONFIGSTRINGS; n++)
				configstrings[n] = new System.Text.StringBuilder().ToString();
			
			for (int n = 0; n < Defines.MAX_CLIENTS; n++)
				clientinfo[n] = new clientinfo_t();
		}
		//
		//	   the client_state_t structure is wiped completely at every
		//	   server map change
		//
		internal int timeoutcount;
		
		internal int timedemo_frames;
		internal int timedemo_start;
		
		public bool refresh_prepped; // false if on new level or new ref dll
		public bool sound_prepped; // ambient sounds can start
		internal bool force_refdef; // vid has changed, so we can't use a paused refdef
		
		internal int parse_entities; // index (not anded off) into cl_parse_entities[]
		
		internal usercmd_t cmd = new usercmd_t();
		//UPGRADE_NOTE: The initialization of  'cmds' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal usercmd_t[] cmds; // each mesage will send several old cmds
		
		//UPGRADE_NOTE: The initialization of  'cmd_time' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal int[] cmd_time; // time sent, for calculating pings
		//UPGRADE_NOTE: The initialization of  'predicted_origins' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal short[][] predicted_origins; // for debug comparing against server
		
		internal float predicted_step; // for stair up smoothing
		internal int predicted_step_time;
		
		internal float[] predicted_origin = new float[]{0, 0, 0}; // generated by CL_PredictMovement
		internal float[] predicted_angles = new float[]{0, 0, 0};
		internal float[] prediction_error = new float[]{0, 0, 0};
		
		public frame_t frame = new frame_t(); // received from server
		internal int surpressCount; // number of messages rate supressed
		//UPGRADE_NOTE: The initialization of  'frames' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal frame_t[] frames;
		
		// the client maintains its own idea of view angles, which are
		// sent to the server each frame.  It is cleared to 0 upon entering each level.
		// the server sends a delta each frame which is added to the locally
		// tracked view angles to account for standing on rotating objects,
		// and teleport direction changes
		public float[] viewangles = new float[]{0, 0, 0};
		
		public int time; // this is the time value that the client
		// is rendering at.  always <= cls.realtime
		internal float lerpfrac; // between oldframe and frame
		
		internal refdef_t refdef = new refdef_t();
		
		internal float[] v_forward = new float[]{0, 0, 0};
		internal float[] v_right = new float[]{0, 0, 0};
		internal float[] v_up = new float[]{0, 0, 0}; // set when refdef.angles is set
		
		//
		// transient data from server
		//
		
		internal System.String layout = ""; // general 2D overlay
		//UPGRADE_NOTE: The initialization of  'inventory' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal int[] inventory;
		
		//
		// non-gameserver infornamtion
		// FIXME: move this cinematic stuff into the cin_t structure
		internal ByteBuffer cinematic_file;
		
		internal int cinematictime; // cls.realtime for first cinematic frame
		internal int cinematicframe;
		internal sbyte[] cinematicpalette = new sbyte[768];
		internal bool cinematicpalette_active;
		
		//
		// server state information
		//
		internal bool attractloop; // running the attract loop, any key will menu
		internal int servercount; // server identification for prespawns
		internal System.String gamedir = "";
		public int playernum;
		
		//UPGRADE_NOTE: The initialization of  'configstrings' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		public System.String[] configstrings;
		
		//
		// locally derived information from server state
		//
		//UPGRADE_NOTE: The initialization of  'model_draw' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal model_t[] model_draw;
		//UPGRADE_NOTE: The initialization of  'model_clip' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal cmodel_t[] model_clip;
		
		//UPGRADE_NOTE: The initialization of  'sound_precache' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		public sfx_t[] sound_precache;
		//UPGRADE_NOTE: The initialization of  'image_precache' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal image_t[] image_precache;
		
		//UPGRADE_NOTE: The initialization of  'clientinfo' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		internal clientinfo_t[] clientinfo;
		internal clientinfo_t baseclientinfo = new clientinfo_t();
	}
}